using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Ted_D_Bear
{
    class Player : CBaseObject
    {
        // Animation representing the player
        public Texture2D PlayerTexture;

        // Edit by Dave - Moved this into the BaseObject Class.
        // Will remove this from Player once it's fully tested
        // Position of the Player relative to the upper left side of the screen
        //public Vector2 Position;

        // State of the player
        //public bool Active;

        // Amount of hit points that player has
        //public int Health;


        override public void Initialize(Texture2D texture, Vector2 position)
        {
            PlayerTexture = texture;
            m_v2Positon = position;
            SetLayer(Layer.FRONT);
            SetObjType(ObjType.PLAYER);
        }

        override public void Update(GameTime gameTime)
        {
            Vector2 leftStick = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left;

            if (leftStick.X >= 0.3f)
            {
                m_v2Positon.X += (leftStick.X*3.0f) * 30.0f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (leftStick.X <= -0.3f)
            {
                m_v2Positon.X += (leftStick.X * 3.0f) * 30.0f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            if (leftStick.Y >= 0.3f)
            {
                m_v2Positon.Y += (leftStick.Y * -3.0f) * 30.0f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (leftStick.Y <= -0.3f)
            {
                m_v2Positon.Y += (leftStick.Y * -3.0f) * 30.0f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

        }

        override public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(PlayerTexture, m_v2Positon, Color.White);
        }

        

        // Get the width of the player
        public int Width
        {
            get { return PlayerTexture.Width; }
        }

        // Get the height of the player
        public int Height
        {
            get { return PlayerTexture.Height; }
        }
    }
}
